from pydantic import BaseModel, Field
from typing import Optional, List
from app.schemas.base import BaseSchema

class RoleBase(BaseModel):
    """角色基础模式"""
    name: str = Field(..., description="角色名称")
    code: str = Field(..., description="角色编码")
    description: Optional[str] = Field(None, description="角色描述")
    status: bool = Field(True, description="状态：True-启用，False-禁用")

class RoleCreate(RoleBase):
    """创建角色模式"""
    permission_ids: List[int] = Field(default=[], description="权限ID列表")

class RoleUpdate(RoleBase):
    """更新角色模式"""
    name: Optional[str] = Field(None, description="角色名称")
    code: Optional[str] = Field(None, description="角色编码")
    permission_ids: Optional[List[int]] = Field(None, description="权限ID列表")

class RoleInDB(RoleBase, BaseSchema):
    """数据库中的角色模式"""
    pass

class RoleOut(RoleInDB):
    """角色输出模式"""
    permissions: List[dict] = Field(default=[], description="权限列表")